package database

import (
	"cache-go/interface/redis"
	"strings"
)

var cmdTable = make(map[string]*command)

type command struct {
	name     string
	executor ExecFunc
	arity    int
	flags    int
}

type ExecFunc func(db *DB, args [][]byte) redis.Reply

func registerCommand(name string, executor ExecFunc, arity int, flags int) *command {
	name = strings.ToLower(name)
	cmd := &command{
		name:     name,
		executor: executor,
		arity:    arity,
		flags:    flags,
	}
	cmdTable[name] = cmd
	return cmd
}
